<template>
  <view class="box">
    <view class="contain">
      <view class="top">
        <view class="one">请选择您的账号类型</view>
        <view class="two">请选择您的身份</view>
      </view>
      <view class="middle" @click="goRecruitLogin">
        <view class="m_text">我要找工作</view>
        <image src="http://wangxinbao.oss-cn-beijing.aliyuncs.com/2024/05/21/c03f66b528c245b1b2b2afc86392ba77.png"
          mode="scaleToFill" />
      </view>
      <view class="middle" @click="goEnteriseLogin">
        <view class="m_text">
          <view>我要招人/</view>
          <view>我要找人干活</view>
        </view>
        <image src="http://wangxinbao.oss-cn-beijing.aliyuncs.com/2024/05/21/c6f85c4843414393a6ba500b88abbf30.png"
          mode="scaleToFill" />
      </view>
    </view>
  </view>
</template>

<script>
import { getInfo } from "@/api/login";
import config from "../../../../config";
import { getToken } from "@/utils/auth";

export default {
  components: {},
  data() {
    return {
    };
  },
  computed: {},
  // 监控data中的数据变化
  watch: {},
  onLoad(options) {
    let timeout = 10000;
    const baseUrl = config.baseUrl;
    uni
      .request({
        method: "get",
        timeout: timeout,
        url: baseUrl + '/xcx/getInfo',
        dataType: "json",
        header: {
          "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
          "Authorization": "Bearer " + getToken()
        },
      })
      .then((res) => {
        if(res.code===200){
          if (res.data.data.currentLoginType && res.data.data.storeStatus === '1') {
          if (res.data.data.entDataStatus === '1') {
            this.$store.commit("setUserType", res.data.data.currentLoginType);
            const type = this.$store.state.userType
            uni.switchTab({
              url: '/pages/tabbarChange/firstPage/index'
            })
            console.log(type, 111);
            this.$store.dispatch("IsRecruit", type);
          }
        }
        }
        // 四种情况会停留该页面，登录状态过时，未完善资料，未绑定门店，未选择身份
      })
    if (options.phonenumber || options.storeId) {
      console.log('~~~', options)
      //记录扫码进来的数据标注为扫码用户
      this.$store.commit("steScanStatus", { storeId: options.storeId, isScan: 1});
      uni.setStorageSync('scanStatus', JSON.stringify({ ...options, isScan: 1 }))
      uni.setStorageSync('storeId', JSON.stringify(options.storeId))
      if(options.phonenumber){
        this.$store.commit("steScanStatus", { storeId: options.storeId, isScan: 1, phonenumber: options.phonenumber });
      }
    }
  },
  onShow() {
  },
  onReady() { },
  methods: {
    goRecruitLogin() {
      let that = this
      uni.showModal({
        title: "提示",
        content: "是否选择该身份",
        cancelText: "取消",
        confirmText: "确定",
        success: function (res) {
          if (res.confirm) {
            uni.setStorageSync('userType', '1')
            that.$store.commit("setUserType", "1");
            const type = that.$store.state.userType
            // let timeout = 10000;
            // const baseUrl = config.baseUrl;
            // uni.request({
            //   method: "POST",
            //   timeout: timeout,
            //   url: baseUrl + '/xcx/xcxQhLogin',
            //   dataType: "json",
            //   header: {
            //     "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            //     "Authorization": "Bearer " + getToken()
            //   },
            //   data: {
            //     type: '1'
            //   }
            // })
            //   .then((res) => { })
            // that.$store.dispatch("CutLogin", { type });
            uni.navigateTo({
              url: "/pages/recruit/login/index",
            })
            that.$store.dispatch("IsRecruit", type);
          }
        },
      });
    },
    goEnteriseLogin() {
      let that = this
      uni.showModal({
        title: "提示",
        content: "是否选择该身份",
        cancelText: "取消",
        confirmText: "确定",
        success: function (res) {
          let timeout = 10000;
          const baseUrl = config.baseUrl;
          if (res.confirm) {
            uni.setStorageSync('userType', '2')
            that.$store.commit("setUserType", "2");
            const type = that.$store.state.userType
            // uni.request({
            //   method: "POST",
            //   timeout: timeout,
            //   url: baseUrl + '/xcx/xcxQhLogin',
            //   dataType: "json",
            //   header: {
            //     "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            //     "Authorization": "Bearer " + getToken()
            //   },
            //   data: {
            //     type: '2'
            //   }
            // })
            //   .then((res) => { })
            uni.navigateTo({
              url: "/pages/recruit/login/index",
            })
            that.$store.dispatch("IsRecruit", type);
          }
        },
      });
    }
  },
};
</script>
<style lang="scss" scoped>
.box {
  margin-top: 180rpx;

  .contain {
    padding: 0 64rpx;

    .top {
      margin-top: 68rpx;

      .one {
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 40rpx;
        color: #000000e0;
        letter-spacing: 0;
      }

      .two {
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 28rpx;
        color: #00000073;
        letter-spacing: 0;
        margin-top: 10rpx;
      }
    }

    .middle {
      width: 622rpx;
      height: 224rpx;
      background: #eeeeee;
      border-radius: 24rpx;
      margin-top: 32rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 48rpx;
      box-sizing: border-box;

      .m_text {
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 36rpx;
        color: #000000e0;
        letter-spacing: 0;
      }

      image {
        width: 96rpx;
        height: 96rpx;
      }
    }
  }
}
</style>
